package com.hotel.controller;

import com.hotel.pojo.Admin;
import com.hotel.service.AdminServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/admin")

public class AdminController {

    @Autowired
    AdminServiceImpl adminService;


    /*
    * 1.考生登录:姓名+准考证号
    * */
    @RequestMapping("/login")
    public String login(String username, String password) {
        //准考证号必须是10位并且是数字
        if (password.length() == 10 && password.matches("[0-9]+")){
            //准考证号必须是10位并且是数字
            Admin admin = adminService.findAdmin(username, password);
            if (admin != null) {
                return "suc_a";
            } else {
                return "error";
            }
        } else {
            return "error";
        }
    }

    @RequestMapping("/updatePwd")
    public String update(Admin admin) {
        adminService.updatePwd(admin);
        System.out.println(admin);
        return "suc_a";
    }
}
